-
Notifications
You must be signed in to change notification settings - Fork 8
feat!: Make array.get
give back the passed array
#2110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
array.get
give back the passed array
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/arrays #2110 +/- ##
===============================================
+ Coverage 83.38% 83.40% +0.01%
===============================================
Files 225 226 +1
Lines 42335 42444 +109
Branches 38388 38497 +109
===============================================
+ Hits 35303 35399 +96
- Misses 5215 5226 +11
- Partials 1817 1819 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -30,13 +30,13 @@ pub trait ArrayOpBuilder<AK: ArrayKind>: Dataflow { | |||
size: u64, | |||
input: Wire, | |||
index: Wire, | |||
) -> Result<Wire, BuildError> { | |||
) -> Result<(Wire, Wire), BuildError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't hurt to document the trait method saying which output is which.
(none of the other methods have docs though -.-)
Feature branch for improved array lowering. * The old `array` type is now called `value_array` and lives in a separate extension * The default `array` is now a linear type with additional `clone` and `discard` operations * To avoid code duplication, array operations and values are now defined generically over a new `ArrayKind` trait that is instantiated with `Array` (the linear one) and `VArray` (the copyable one) to generate the `array` and `value_array` extensions * An `array<n, T>` is now lowered to a fat pointer `{ptr, usize}` where `ptr` is a heap allocated pointer of size at least `n * sizeof(T)` and the `usize` is an offset pointing to the first element (i.e. the first element is at `ptr + offset * sizeof(T)`). The rational behind the additional offset is the `pop_left` operation which bumps the offset instead of mutating the pointer. This way, we can still free the original pointer when the array is discarded after a pop. Tracked PRs: * #2097 (closes #2066) * #2100 * #2101 * #2110 * #2112 (closes #2067) * #2119 * #2125 (closes #2124) BREAKING CHANGE: `std.collections.array` is now a linear type, even if the contained elements are copyable. Use the new `std.collections.value_array` for an array with the previous copyable semantics. BREAKING CHANGE: `std.collections.array.get` now also returns the passed array as an extra output BREAKING CHANGE: `ArrayOpBuilder` was moved from `hugr_core::std_extensions::collections::array::op_builder` to `hugr_core::std_extensions::collections::array`.
Feature branch for improved array lowering. * The old `array` type is now called `value_array` and lives in a separate extension * The default `array` is now a linear type with additional `clone` and `discard` operations * To avoid code duplication, array operations and values are now defined generically over a new `ArrayKind` trait that is instantiated with `Array` (the linear one) and `VArray` (the copyable one) to generate the `array` and `value_array` extensions * An `array<n, T>` is now lowered to a fat pointer `{ptr, usize}` where `ptr` is a heap allocated pointer of size at least `n * sizeof(T)` and the `usize` is an offset pointing to the first element (i.e. the first element is at `ptr + offset * sizeof(T)`). The rational behind the additional offset is the `pop_left` operation which bumps the offset instead of mutating the pointer. This way, we can still free the original pointer when the array is discarded after a pop. Tracked PRs: * #2097 (closes #2066) * #2100 * #2101 * #2110 * #2112 (closes #2067) * #2119 * #2125 (closes #2124) BREAKING CHANGE: `std.collections.array` is now a linear type, even if the contained elements are copyable. Use the new `std.collections.value_array` for an array with the previous copyable semantics. BREAKING CHANGE: `std.collections.array.get` now also returns the passed array as an extra output BREAKING CHANGE: `ArrayOpBuilder` was moved from `hugr_core::std_extensions::collections::array::op_builder` to `hugr_core::std_extensions::collections::array`.
Since the array type is now linear following #2097, we need to change the signature of the
array.get
op to give the passed array back to the user.BREAKING CHANGE:
std.collections.array.get
now also returns the passed array as an extra output